<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Image Data in Memory</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK-PixBuf Reference Manual">
<link rel="up" href="rn01.html" title="API Reference">
<link rel="prev" href="gdk-pixbuf-File-saving.html" title="File saving">
<link rel="next" href="gdk-pixbuf-Inline-data.html" title="Inline data">
<meta name="generator" content="GTK-Doc V1.17.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-pixbuf-File-saving.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK-PixBuf Reference Manual</th>
<td><a accesskey="n" href="gdk-pixbuf-Inline-data.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-pixbuf-Image-Data-in-Memory.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk-pixbuf-Image-Data-in-Memory.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk-pixbuf-Image-Data-in-Memory"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-pixbuf-Image-Data-in-Memory.top_of_page"></a>Image Data in Memory</span></h2>
<p>Image Data in Memory — Creating a pixbuf from image data that is already in memory.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk-pixbuf-Image-Data-in-Memory.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;

<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()">gdk_pixbuf_new</a>                      (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()">gdk_pixbuf_new_from_data</a>            (<em class="parameter"><code>const <span class="type">guchar</span> *data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> rowstride</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-Reference-Counting-and-Memory-Mangement.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
                                                         <em class="parameter"><code><span class="type">gpointer</span> destroy_fn_data</code></em>);
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()">gdk_pixbuf_new_from_xpm_data</a>        (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-inline" title="gdk_pixbuf_new_from_inline ()">gdk_pixbuf_new_from_inline</a>          (<em class="parameter"><code><span class="type">gint</span> data_length</code></em>,
                                                         <em class="parameter"><code>const <span class="type">guint8</span> *data</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> copy_pixels</code></em>,
                                                         <em class="parameter"><code><span class="type">GError</span> **error</code></em>);
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-subpixbuf" title="gdk_pixbuf_new_subpixbuf ()">gdk_pixbuf_new_subpixbuf</a>            (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *src_pixbuf</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_x</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_y</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);
<a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()">gdk_pixbuf_copy</a>                     (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.description"></a><h2>Description</h2>
<p>
The most basic way to create a pixbuf is to wrap an existing pixel
buffer with a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure.  You can use the
<a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a> function to do this You need to specify
the destroy notification function that will be called when the
data buffer needs to be freed; this will happen when a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
is finalized by the reference counting functions If you have a
chunk of static data compiled into your application, you can pass
in <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> as the destroy notification function so that the data
will not be freed.
</p>
<p>
The <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a> function can be used as a convenience to
create a pixbuf with an empty buffer.  This is equivalent to
allocating a data buffer using <code class="function"><code class="function">malloc()</code></code> and 
then wrapping it with <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-data" title="gdk_pixbuf_new_from_data ()"><code class="function">gdk_pixbuf_new_from_data()</code></a>. The <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new" title="gdk_pixbuf_new ()"><code class="function">gdk_pixbuf_new()</code></a> 
function will compute an optimal rowstride so that rendering can be 
performed with an efficient algorithm.
</p>
<p>
As a special case, you can use the <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-xpm-data" title="gdk_pixbuf_new_from_xpm_data ()"><code class="function">gdk_pixbuf_new_from_xpm_data()</code></a>
function to create a pixbuf from inline XPM image data.
</p>
<p>
You can also copy an existing pixbuf with the <a class="link" href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-copy" title="gdk_pixbuf_copy ()"><code class="function">gdk_pixbuf_copy()</code></a>
function.  This is not the same as just doing a <code class="function">g_object_ref()</code>
on the old pixbuf; the copy function will actually duplicate the
pixel data in memory and create a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure for it.
</p>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="gdk-pixbuf-new"></a><h3>gdk_pixbuf_new ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new                      (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>
Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure and allocates a buffer for it.  The 
buffer has an optimal rowstride.  Note that the buffer is not cleared;
you will have to fill it completely yourself.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Color space for image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the image should have transparency information</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per color sample</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a reference count of 1, or
<a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if not enough memory could be allocated for the image buffer.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-data"></a><h3>gdk_pixbuf_new_from_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_data            (<em class="parameter"><code>const <span class="type">guchar</span> *data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkColorspace" title="enum GdkColorspace"><span class="type">GdkColorspace</span></a> colorspace</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> has_alpha</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> bits_per_sample</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> rowstride</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk-pixbuf-Reference-Counting-and-Memory-Mangement.html#GdkPixbufDestroyNotify" title="GdkPixbufDestroyNotify ()"><span class="type">GdkPixbufDestroyNotify</span></a> destroy_fn</code></em>,
                                                         <em class="parameter"><code><span class="type">gpointer</span> destroy_fn_data</code></em>);</pre>
<p>
Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> out of in-memory image data.  Currently only RGB
images with 8 bits per sample are supported.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Image data in 8-bit/sample packed format. <span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym>][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> char]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>colorspace</code></em> :</span></p></td>
<td>Colorspace for the image data</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>has_alpha</code></em> :</span></p></td>
<td>Whether the data has an opacity channel</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>bits_per_sample</code></em> :</span></p></td>
<td>Number of bits per sample</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>Width of the image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>Height of the image in pixels, must be &gt; 0</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>rowstride</code></em> :</span></p></td>
<td>Distance in bytes between row starts</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn</code></em> :</span></p></td>
<td>Function used to free the data when the pixbuf's reference count
drops to zero, or <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if the data should not be freed. <span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_fn_data</code></em> :</span></p></td>
<td>Closure data to pass to the destroy notification function. <span class="annotation">[<acronym title="This parameter is a 'user_data', for callbacks; many bindings can pass NULL here."><span class="acronym">closure</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference count of 1. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-xpm-data"></a><h3>gdk_pixbuf_new_from_xpm_data ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_xpm_data        (<em class="parameter"><code>const <span class="type">char</span> **data</code></em>);</pre>
<p>
Creates a new pixbuf by parsing XPM data in memory.  This data is commonly
the result of including an XPM file into a program's C source.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Pointer to inline XPM data.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created pixbuf with a reference count of 1.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-from-inline"></a><h3>gdk_pixbuf_new_from_inline ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_from_inline          (<em class="parameter"><code><span class="type">gint</span> data_length</code></em>,
                                                         <em class="parameter"><code>const <span class="type">guint8</span> *data</code></em>,
                                                         <em class="parameter"><code><span class="type">gboolean</span> copy_pixels</code></em>,
                                                         <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre>
<p>
Create a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> from a flat representation that is suitable for
storing as inline data in a program. This is useful if you want to
ship a program with images, but don't want to depend on any
external files.
</p>
<p>
gdk-pixbuf ships with a program called <span class="command"><strong>gdk-pixbuf-csource</strong></span> 
which allows for conversion of <a href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbufs</span></a> into such a inline representation.
In almost all cases, you should pass the <code class="option">--raw</code> flag to
<span class="command"><strong>gdk-pixbuf-csource</strong></span>. A sample invocation would be:
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="normal">gdk</span><span class="symbol">-</span><span class="normal">pixbuf</span><span class="symbol">-</span><span class="normal">csource </span><span class="symbol">--</span><span class="normal">raw </span><span class="symbol">--</span><span class="normal">name</span><span class="symbol">=</span><span class="usertype">myimage_inline</span><span class="normal"> myimage</span><span class="symbol">.</span><span class="normal">png</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<p>
For the typical case where the inline pixbuf is read-only static data,
you don't need to copy the pixel data unless you intend to write to
it, so you can pass <code class="literal">FALSE</code> for <em class="parameter"><code>copy_pixels</code></em>.  (If you pass 
<code class="option">--rle</code> to <span class="command"><strong>gdk-pixbuf-csource</strong></span>, a copy 
will be made even if <em class="parameter"><code>copy_pixels</code></em> is <code class="literal">FALSE</code>, so using this option is 
generally a bad idea.)
</p>
<p>
If you create a pixbuf from const inline data compiled into your
program, it's probably safe to ignore errors and disable length checks, 
since things will always succeed:
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="normal">pixbuf </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="gdk-pixbuf-Image-Data-in-Memory.html#gdk-pixbuf-new-from-inline">gdk_pixbuf_new_from_inline</a></span><span class="normal"> </span><span class="symbol">(-</span><span class="number">1</span><span class="symbol">,</span><span class="normal"> myimage_inline</span><span class="symbol">,</span><span class="normal"> FALSE</span><span class="symbol">,</span><span class="normal"> <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<p>
For non-const inline data, you could get out of memory. For untrusted 
inline data located at runtime, you could have corrupt inline data in 
addition.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_length</code></em> :</span></p></td>
<td>Length in bytes of the <em class="parameter"><code>data</code></em> argument or -1 to
disable length checks</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>Byte data containing a serialized <a class="link" href="gdk-pixbuf-Inline-data.html#GdkPixdata" title="struct GdkPixdata"><span class="type">GdkPixdata</span></a> structure</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>copy_pixels</code></em> :</span></p></td>
<td>Whether to copy the pixel data, or use direct pointers
<em class="parameter"><code>data</code></em> for the resulting pixbuf</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>
<span class="type">GError</span> return location, may be <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> to ignore errors</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> structure with a reference,
count of 1, or <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if an error occurred.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-new-subpixbuf"></a><h3>gdk_pixbuf_new_subpixbuf ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_new_subpixbuf            (<em class="parameter"><code><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *src_pixbuf</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_x</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> src_y</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> width</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> height</code></em>);</pre>
<p>
Creates a new pixbuf which represents a sub-region of
<em class="parameter"><code>src_pixbuf</code></em>. The new pixbuf shares its pixels with the
original pixbuf, so writing to one affects both.
The new pixbuf holds a reference to <em class="parameter"><code>src_pixbuf</code></em>, so
<em class="parameter"><code>src_pixbuf</code></em> will not be finalized until the new pixbuf
is finalized.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_pixbuf</code></em> :</span></p></td>
<td>a <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_x</code></em> :</span></p></td>
<td>X coord in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>src_y</code></em> :</span></p></td>
<td>Y coord in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>width of region in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>height of region in <em class="parameter"><code>src_pixbuf</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new pixbuf. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="gdk-pixbuf-copy"></a><h3>gdk_pixbuf_copy ()</h3>
<pre class="programlisting"><a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="returnvalue">GdkPixbuf</span></a> *         gdk_pixbuf_copy                     (<em class="parameter"><code>const <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> *pixbuf</code></em>);</pre>
<p>
Creates a new <a class="link" href="gdk-pixbuf-The-GdkPixbuf-Structure.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> with a copy of the information in the specified
<em class="parameter"><code>pixbuf</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>pixbuf</code></em> :</span></p></td>
<td>A pixbuf.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly-created pixbuf with a reference count of 1, or <a href="/home/mclasen/gnome/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if
not enough memory could be allocated. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1">
<a name="gdk-pixbuf-Image-Data-in-Memory.see-also"></a><h2>See Also</h2>
gdk_pixbuf_finalize().
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17.1</div>
</body>
</html>